package cn.ymjr.customer.controller;

import cn.ymjr.customer.form.DecryptForm;
import cn.ymjr.customer.service.CustomerService;
import cn.ymjr.sys.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Tiny
 * @create 2022/4/1 14:12
 */
@CrossOrigin("*")
@RestController
@RequestMapping("customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @RequestMapping(value="/wx",method = RequestMethod.GET)
    public Result getOpenId(String code,Integer inviteId){
        try {
            return customerService.getOpenId(code,inviteId);
        } catch (Exception e) {
            return new Result(false,"获取失败");
        }
    }
    @RequestMapping(value = "decodePhone",method = RequestMethod.POST)
    public Result login(@RequestBody DecryptForm decryptForm){
        try {
            return customerService.login(decryptForm);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"获取失败");
        }
    }
}
